/*
 * @Author: yanjikun
 * @Date: 2022-04-14 15:26:34
 * @LastEditors: yanjikun
 * @LastEditTime: 2022-04-26 14:01:27
 * @Description: file content
 */

import inputProps from 'ant-design-vue/lib/input/inputProps'
import { selectProps } from 'ant-design-vue/lib/select'
import { treeSelectProps } from 'ant-design-vue/lib/tree-select'
import { ExtractPropTypes, PropType } from 'vue'
/**远程获取下拉选项组件Props */
export const apiSelectProps = {
  ...selectProps(),
  value: [Array, Object, String, Number],
  numberToString: {
    type: Boolean as PropType<boolean>,
    default: false
  },
  api: {
    type: Function as PropType<(arg?: Recordable) => Promise<any>>,
    default: null
  },
  params: {
    type: Object as PropType<Recordable>,
    default: () => ({})
  },
  resultField: {
    type: String as PropType<string>,
    default: ''
  },
  labelField: {
    type: String as PropType<string>,
    default: 'label'
  },
  valueField: {
    type: String as PropType<string>,
    default: 'value'
  },
  immediate: {
    type: Boolean as PropType<boolean>,
    default: true
  },
  alwaysLoad: {
    type: Boolean as PropType<boolean>,
    default: false
  }
}

export type ApiSelectProps = Partial<ExtractPropTypes<typeof apiSelectProps>>

/**远程获取树选择组件Props */
export const apiTreeSelectProps = {
  ...treeSelectProps(),
  api: {
    type: Function as PropType<(args?: Recordable) => Promise<any>>,
    default: null
  },
  params: {
    type: Object as PropType<Recordable>,
    default: () => ({})
  },
  immediate: {
    type: Boolean as PropType<boolean>,
    default: true
  },
  resultField: {
    type: String as PropType<string>,
    default: ''
  },
  listToTree: {
    type: Boolean as PropType<boolean>,
    default: true
  },
  alwaysLoad: {
    type: Boolean as PropType<boolean>,
    default: false
  }
}

export type ApiTreeSelectProps = Partial<ExtractPropTypes<typeof apiTreeSelectProps>>

/**选择图标组件Props */
export const iconsSelectProps = {
  ...inputProps(),
  value: {
    type: String as PropType<string>
  }
}

export type IconsSelectProps = Partial<ExtractPropTypes<typeof iconsSelectProps>>

/**通过地图选择地址组件Props */
export const addressSelectProps = {
  ...inputProps(),
  value: {
    type: Object as PropType<Recordable>
  },
  /**详细地址字段 */
  addressField: {
    type: String as PropType<string>,
    default: 'address'
  },
  /**纬度字段 */
  latField: {
    type: String as PropType<string>,
    default: 'latitude'
  },
  /**经度字段 */
  lngField: {
    type: String as PropType<string>,
    default: 'longitude'
  }
}
export type AddressSelectProps = Partial<ExtractPropTypes<typeof addressSelectProps>>
